﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>

<%
	dim rs,sql,ext,id,zf2,down,VIP,zf,classid,gm,nid,FileUrl


	id=Request.QueryString("id")
	if id="" then id=0
	if not isnumeric(id) then id=0
	id=clng(id)

	ext=Request.QueryString("ext")
	if ext="" then ext=1
	if not isnumeric(ext) then ext=1
	ext=clng(ext)

	Set Rs = Server.CreateObject("Adodb.Recordset")


	if sid<>"Null" then


	Sql = "select money,vip,id from qingtian_user where sid='"&md5(sid) & md5(strReverse(sid))&"'"
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
		nid=rs("id")
		zf2=rs("money")
	end if
	Rs.close	



	Sql = "select id from qingtian_paym where ext="&ext&" and listid="&id&" and  nid="&nid&""
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
		gm=1
	else
		gm=0
	end if
	Rs.close	


	else
		gm=0
		zf2=0
	end if



	if ext=1 then
	Sql = "select VIP,zf from qingtian_fileli where id="&id
	FileUrl="fileve.asp"
	elseif ext=2 then
	Sql = "select VIP,zf from qingtian_viewli where id="&id
	FileUrl="articview.asp"
	elseif ext=3 then
	Sql = "select VIP,zf from qingtian_photoli where id="&id
	FileUrl="photove.asp"
	elseif ext=7 then
	Sql = "select VIP,zf from qingtian_bbsclass where id="&id
	FileUrl="/bbs/tian.asp"
	else
	Sql = "select VIP,zf from qingtian_class where id="&id
	FileUrl="tian.asp"
	end if

	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
		vip=rs("vip")
		zf=rs("zf")
	else
		viphy=0
		vip=0
		zf=0
	end if
	Rs.close	
	set rs=nothing
		if vip=1 then
			if sid<>"Null" then
				if clng(zf2)>=clng(zf) then
					down=true
				else
					down=false
				end if
			else
				down=false
			end if
		else
			down=true

		end if

select case v
case "0"
we0="<br/>"
hr="--------<br/>"
%>
<card title="购买" ontimer="<%=FileUrl%>?id=<%=id%>&amp;sid=<%=sidd%>"><timer value="30"/><p align="<%=qingtian.px%>">
<%
case "1"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
%>
<title>购买</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%

End Select
%><%

		if sid="Null" then
			%><%=we%>购买出错!请登陆后再购买!<%=we0%><%
		elseif down=true then
			if gm=0 then
			conn.execute("update qingtian_user set [money]=[money]-"&zf&" where sid='"&md5(sid) & md5(strReverse(sid))&"'")
			conn.execute("insert into qingtian_paym ([ext],nid,listid,zf) values ("&ext&","&nid&","&id&","&zf&")")
			%><%=we%>购买成功,系统扣除了你<%=zf%><%=qingtian.bi%>,你当前<%=qingtian.bi%>为<%=zf2%>!<%=we0%><%
			else
			%><%=we%>你已经购买过了,请不要重复购买!<%=we0%><%
			end if
		else
				%><%=we%>你的账户余额不足!购买需<%=qingtian.bi%><%=zf%>,你当前<%=qingtian.bi%>为<%=zf2%>!<%=we0%>
<%
		end if

   		    %><%=hr%><%=sou%><a href="<%=FileUrl%>?id=<%=id%>&amp;sid=<%=sidd%>">返回来源页</a><%=we0%>
<%
end Function
%>
